/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.vinavac.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Quang <quangtin3@gmail.com>
 */
@Entity
@Table(name = "study_status")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StudyStatus.findAll", query = "SELECT s FROM StudyStatus s"),
    @NamedQuery(name = "StudyStatus.findById", query = "SELECT s FROM StudyStatus s WHERE s.id = :id"),
    @NamedQuery(name = "StudyStatus.findByDescription", query = "SELECT s FROM StudyStatus s WHERE s.description = :description")})
public class StudyStatus implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 32)
    @Column(name = "ID")
    private String id;
    @Size(max = 256)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "studyStatus")
    private List<Subject> subjectList;

    public StudyStatus() {
    }

    public StudyStatus(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<Subject> getSubjectList() {
        return subjectList;
    }

    public void setSubjectList(List<Subject> subjectList) {
        this.subjectList = subjectList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StudyStatus)) {
            return false;
        }
        StudyStatus other = (StudyStatus) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getDescription();
    }
}
